﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="rengongchengben.aspx.cs" Inherits="Catering.Catering_Page.Kufang.rengongchengben" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<%@ Register Src="../../UCPanle/DDLTool.ascx" TagName="DDLTool" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../Style/head.css" />
    <link rel="stylesheet" type="text/css" href="../../Style/center.css" />
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Style/xxk.js" type="text/javascript"></script>
    <script src="../../Style/zhezhao.js" type="text/javascript"></script>
    <script src="../../Scripts/Calendar.js" type="text/javascript"></script>
    <style type="text/css">
    .tc_css { border: solid 10px #898989; background: #fff; width:540px; z-index: 1001; position: absolute; display: none; top: 30%; left: 50%; margin: -140px 0 0 -400px; margin-left: -25%; display: none; }
    .tc_css h2 { width: 100%; height: 30px; line-height: 30px; background: url(../../Images/div_h1_bg_02.gif) 0 0 repeat-x; font-size: 14px; font-weight: 400; }
    .tc_css b {margin-left: 10px; display: block; float: left; }
    .tc_css span { cursor: pointer; margin-right: 10px; display: block; float: right; }
    .tc_conter { width: 100%; padding:10px auto; }
    .td_bgcolor td{ background-color:transparent;}
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#dl_GroupList").change(function () {
                var zyqid = $("#dl_GroupList").val();

                $.ajax({
                    type: "Post",
                    url: "rengongchengben.aspx/GetBZOption",
                    data: "{'strid':'" + zyqid + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        $("#dl_ClassList").html(data.d);
                    }
                });
            });
//            var groupid=<%=m_GropuID %>;
//            var classid=<%=m_ClassID %>
//            var year=<%=m_Year %>;
//            if(groupid!="") $("#DDLTool1_ddl_Area").val(groupid);
//            if(classid!="") $("#DDLTool1_ddl_class").val(classid);
//            if(year!="") $("#DDLTool1_TextBox1").val(year);
        });
        function ADDLaborCosts() {
            $("#txt_Numbers").val("");
            divshow('div1', 'div_add');
        }

        function AjaxSearch() {
            var zyqid = $("#dl_GroupList").val();
            var bzid = $("#dl_ClassList").val();
            var date = $("#txt_Date").val();
            if (zyqid == "") {
                alert("请选择作业区！");
                return;
            }
            if (bzid == "") {
                alert("请选择班组！");
                return;
            }
            if (date == "") {
                alert("请输入年月！");
                return;
            }
            $.ajax({
                type: "Post",
                url: "rengongchengben.aspx/GetAjaxLadorCosts",
                data: "{'StrGroupID':'" + zyqid + "','StrClassID':'" + bzid + "','StrDate':'" + date + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "1") {
                        alert("请选择作业区！");
                    }
                    else if (data.d == "2") {
                        alert("请选择班组！");
                    }
                    else if (data.d == "3") {
                        alert("请输入年月！");
                    }
                    else {
                        $("#txt_Numbers").val(data.d);
                    }
                }
            });
        }

        function AjaxCheck() {
            var zyqid = $("#dl_GroupList").val();
            var bzid = $("#dl_ClassList").val();
            var date = $("#txt_Date").val();
            var number = $("#txt_Numbers").val();
            if (zyqid == "") {
                alert("请选择作业区！");
                return;
            }
            if (bzid == "") {
                alert("请选择班组！");
                return;
            }
            if (date == "") {
                alert("请输入年月！");
                return;
            }
            $.ajax({
                type: "Post",
                url: "rengongchengben.aspx/ExistLadorCosts",
                data: "{'StrGroupID':'" + zyqid + "','StrClassID':'" + bzid + "','StrDate':'" + date + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "1") {
                        alert("请选择作业区！");
                    }
                    else if (data.d == "2") {
                        alert("请选择班组！");
                    }
                    else if (data.d == "3") {
                        alert("请输入年月！");
                    }
                    else if (data.d == "NO") {
                        if (isNaN(number)) {
                            alert("人工成本输入错误！");
                        }
                        else {
                            AjaxAdd(zyqid, bzid, date, number);
                        }
                    }
                    else {
                        if (confirm("此记录已存在，是否覆盖？")) {
                            if (isNaN(number)) {
                                alert("人工成本输入错误！");
                            }
                            else {
                                AjaxAdd(zyqid, bzid, date, number);
                            }
                        }
                    }
                }
            });
        }

        function AjaxAdd(zyqid, bzid, date, number) {
            var tempzyq = $("#DDLTool1_ddl_Area").val();
            var tempclass = $("#DDLTool1_ddl_class").val();
            var tempyear = $("#DDLTool1_TextBox1").val();
            $.ajax({
                type: "Post",
                url: "rengongchengben.aspx/SetAjaxLadorCosts",
                data: "{'StrGroupID':'" + zyqid + "','StrClassID':'" + bzid + "','StrDate':'" + date + "','Number':'" + number + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "4") {
                        alert("添加成功！");
                        divhidel('div1', 'div_add');
                        location.href = "rengongchengben.aspx?AreaID=" + tempzyq + "&ClassID=" + tempclass + "&Year=" + tempyear;
                    }
                    else if (data.d == "5") {
                        alert("添加失败！");
                    }
                    else if (data.d == "6") {
                        alert("修改成功！");
                        divhidel('div1', 'div_add');
                        location.href = "rengongchengben.aspx?AreaID=" + tempzyq + "&ClassID=" + tempclass + "&Year=" + tempyear;
                    }
                    else if (data.d == "7") {
                        alert("修改失败！");
                    }
                }
            });
        }
    </script>  
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" ScriptMode="Release" runat="server">
    </asp:ScriptManager>    
    <asp:UpdatePanel runat="server" ID="UpdatePanel1">
    <ContentTemplate>
    <div class="Center_Content" id="div2_2" style="display: block">
        <div class="div_0207 left_width500" style="height:34px; width:998px;">
            <table align="left" width="100%" border="0" cellspacing="0" cellpadding="0" class="ckgl_table" style="height:34px;">
                <thead>
                    <tr>
                        <td><uc1:DDLTool ID="DDLTool1" runat="server" /></td>
                        <td>&nbsp;</td>
                        <td align="right" width="100">
                            <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">开始统计</asp:LinkButton>
                        </td>
                        <td align="right" width="100">
                            <a class="input_btn_a" href="javascript:ADDLaborCosts();">添加/修改</a>
                        </td>
                        <td width="10"></td>
                    </tr>
                </thead>
            </table>
        </div>
        <div class="Create_Recipe" style="margin-top:0px;">
            <rsweb:ReportViewer Width="100%" ID="ReportViewer1" Height="500" Visible="false" runat="server" Font-Names="Verdana"
                Font-Size="8pt" InteractiveDeviceInfos="(集合)" WaitMessageFont-Names="Verdana" BackColor="White"
                WaitMessageFont-Size="14pt">
                <LocalReport ReportPath="Catering_Page\Kufang\Report\Cost_Labor.rdlc"></LocalReport>
            </rsweb:ReportViewer>
        </div>
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
    <!--遮罩层-->
    <div id="div1" class="bg"></div>
    <!--弹出层-->
    <div id="div_add" isadd="true" class="tc_css">
        <h2><b>添加/修改人工成本</b><span onclick="divhidel('div1','div_add')" title="关闭">[×]</span></h2>
        <div class="tc_conter">
            <table border="0" cellpadding="0" cellspacing="0" align="center">
                <tr>
                    <td height="40" width="60" align="right">作业区：</td>
                    <td width="110">
                        <asp:DropDownList ID="dl_GroupList" CssClass="select_input_bg" Width="100" runat="server"></asp:DropDownList>
                    </td>
                    <td width="45" align="right">班组：</td>
                    <td width="110"><asp:DropDownList ID="dl_ClassList" CssClass="select_input_bg" Width="100" runat="server"></asp:DropDownList></td>
                    <td height="40" align="right">年月：</td>
                    <td width="70"><asp:TextBox ID="txt_Date" onfocus="WdatePicker({dateFmt:'yyyy-MM'})" runat="server" CssClass="input_bg" style="width:60px;"></asp:TextBox></td>
                    <td>
                        <input type="button" name="sosuo" id="SearchBtn" onclick="AjaxSearch()" value="搜　索" class="input_btn_a" />
                    </td>
                </tr>
                <tr>
                    <td style="border-bottom:1px dashed #ABC2E4" height="1" colspan="7"></td>
                </tr>
                <tr>
                    <td height="40" align="right">人工成本：</td>
                    <td><asp:TextBox ID="txt_Numbers" runat="server" CssClass="input_bg" style="width:90px;"></asp:TextBox></td>
                    <td></td>
                    <td></td>
                    <td colspan="2" align="center"><input type="button" id="btn_tijiao" value="保存" onclick="AjaxCheck()" class="input_btn_a" /></td>
                    <td align="center"><input type="button" id="btn_quxiao" value="取消" onclick="divhidel('div1','div_add')" class="input_btn_a" /></td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
</html>
